<?php

require_once 'common.php';

$act = isset($_REQUEST['act']) && !empty($_REQUEST['act']) ? $_REQUEST['act'] : '';

if ($act == 'checkLogin') {
    $adminRow = M('admin')->where('username = "' . $_REQUEST['username'] . '" and password = "' . md5($_REQUEST['password']) . '"')->find();
    if ($adminRow) {
        $_SESSION['admin_id'] = $adminRow['admin_id'];
        $_SESSION['username'] = $adminRow['username'];
        $_SESSION['admin_role'] = $adminRow['admin_role'];
        returnJson(0, '成功');
    } else {
        returnJson(1, '用户名或者密码错误');
    }
}

display('login');